package com.ruoyi.web.controller.order;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.order.domain.MemberCardOrder;
import com.ruoyi.order.service.IMemberCardOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 会员卡订单Controller
 *
 * @author HHAOYU
 * @date 2021-01-04
 */
@RestController
@RequestMapping("/order/memberCardOrder")
public class MemberCardOrderController extends BaseController
{
    @Autowired
    private IMemberCardOrderService memberCardOrderService;

    /**
     * 查询会员卡订单列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:memberCardOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberCardOrder memberCardOrder)
    {
        startPage();
        List<MemberCardOrder> list = memberCardOrderService.selectMemberCardOrderList(memberCardOrder);
        return getDataTable(list);
    }

    /**
     * 导出会员卡订单列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:memberCardOrder:export')")
    @Log(title = "会员卡订单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MemberCardOrder memberCardOrder)
    {
        List<MemberCardOrder> list = memberCardOrderService.selectMemberCardOrderList(memberCardOrder);
        ExcelUtil<MemberCardOrder> util = new ExcelUtil<MemberCardOrder>(MemberCardOrder.class);
        return util.exportExcel(list, "memberCardOrder");
    }

    /**
     * 获取会员卡订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:memberCardOrder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(memberCardOrderService.selectMemberCardOrderById(id));
    }

    /**
     * 新增会员卡订单
     */
    @PreAuthorize("@ss.hasPermi('cinema:memberCardOrder:add')")
    @Log(title = "会员卡订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberCardOrder memberCardOrder)
    {
        return toAjax(memberCardOrderService.insertMemberCardOrder(memberCardOrder));
    }

    /**
     * 修改会员卡订单
     */
    @PreAuthorize("@ss.hasPermi('cinema:memberCardOrder:edit')")
    @Log(title = "会员卡订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberCardOrder memberCardOrder)
    {
        return toAjax(memberCardOrderService.updateMemberCardOrder(memberCardOrder));
    }

    /**
     * 删除会员卡订单
     */
    @PreAuthorize("@ss.hasPermi('cinema:memberCardOrder:remove')")
    @Log(title = "会员卡订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(memberCardOrderService.deleteMemberCardOrderByIds(ids));
    }
}
